package ${package.Controller};

<#if superControllerClassPackage??>
    import ${superControllerClassPackage};
</#if>

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* ${table.comment!?replace("表","")}
* @author ${author}
* @since ${date}
*/
@RestController
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if entityNameLowerCase??>${entityNameLowerCase}<#else>${table.entityPath}</#if>")
@Api(tags = "${table.comment!?replace("表","")}管理")
public class ${table.controllerName} {

    // ${table.comment!?replace("表","")}
    @Autowired
    private ${entityNameUpperCase}Service ${entityNameLowerCase}Service;

    @PostMapping("/add")
    @ApiOperation(value = "增加${table.comment!?replace("表","")}接口", httpMethod = "POST")
    public R add(@RequestBody @Validated({AddGroup.class}) ${entityNameUpperCase}DTO ${entityNameLowerCase}DTO) {
        // TODO参数校验
        ${entityNameLowerCase}Service.add(${entityNameLowerCase}DTO);
        return R.ok();
    }

    @PostMapping("/update")
    @ApiOperation(value = "编辑${table.comment!?replace("表","")}接口", httpMethod = "POST")
    public R update(@RequestBody @Validated({UpdateGroup.class}) ${entityNameUpperCase}DTO ${entityNameLowerCase}DTO) {
        // TODO参数校验
        ${entityNameLowerCase}Service.update(${entityNameLowerCase}DTO);
        return R.ok();
    }

    @PostMapping("/detail")
    @ApiOperation(value = "${table.comment!?replace("表","")}详细接口", httpMethod = "POST")
    public R<${entityNameUpperCase}VO> detail(@RequestBody ${entityNameUpperCase}DTO ${entityNameLowerCase}DTO) {
        // TODO参数校验
        ${entityNameUpperCase}VO ${entityNameLowerCase}VO = ${entityNameLowerCase}Service.detail(${entityNameLowerCase}DTO);
        return R.ok(${entityNameLowerCase}VO);
    }

    @PostMapping("/list")
    @ApiOperation(value = "${table.comment!?replace("表","")}列表查询接口", httpMethod = "POST")
    public R<List<${entityNameUpperCase}VO>> list(@RequestBody @Validated({SelectGroup.class}) ${entityNameUpperCase}DTO ${entityNameLowerCase}DTO) {
        // TODO参数校验
        Pair<List<${entityNameUpperCase}VO>, Long> pageResult = ${entityNameLowerCase}Service.list(${entityNameLowerCase}DTO);
        return R.ok(pageResult.getKey(), pageResult.getValue());
    }
        
    @PostMapping("/delete")
    @ApiOperation(value = "删除${table.comment!?replace("表","")}接口", httpMethod = "POST")
    public R delete(@RequestBody @Validated({DeleteGroup.class}) ${entityNameUpperCase}DTO ${entityNameLowerCase}DTO) {
        // TODO参数校验
        ${entityNameLowerCase}Service.delete(${entityNameLowerCase}DTO);
        return R.ok();
    }
}
